var http = require('http');
var fs = require('fs');
var URL = 'http://pic.3gbizhi.com/2019/0928/20190928012439343.jpg';

http.get(URL, (res) => {
    var image = [];
    res.on('data', (x) => {
        image.push(x);
    });
    res.on('end', () => {
        fs.writeFile('shiyan2_3_image.jpg', Buffer.concat(image), (err) => {
            if (err) throw err;
            console.log('图片已下载');
        });
    });
}).on('error', (err) => {
    console.log('请求图片失败', err);
});
